//
//  ZBNetworkManager.h
//  ZBDay
//
//  Created by xzb on 2018/2/5.
//  Copyright © 2018年 xzb. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking/AFNetworking.h"


@class ZBResponseModel,ZBDownLoadRespModel;

typedef void (^onZBCompletionBlock)(id result);
typedef void (^onLoadFromCacheBlock)(id result);
typedef void (^onProgressBlock)(id progeress);
typedef void (^onZBErrorBlock)(id error);
typedef void (^onDownloadRespBlock)(ZBDownLoadRespModel *respModel);

@interface ZBNetworkManager : NSObject

+ (instancetype)instance;

+ (AFHTTPSessionManager *)AFHTTPSessionManager;

+ (NSURLSessionTask *)sendRequestType:(NSString *)type urlStr:(NSString *)urlStr params:(NSDictionary *)params headers:(NSDictionary *)headers success:(onZBCompletionBlock)success failure:(onZBErrorBlock)failure;


+ (NSURLSessionUploadTask *)uploadFileWithUrl:(NSString *)url
                                       params:(NSDictionary *)dict
                                         data:(NSData *)data
                                CompleteBlock:(onZBCompletionBlock)onComplete
                                 ZBErrorBlock:(onZBErrorBlock)onError
                                ProgressBlock:(onProgressBlock)progressBlock;

- (NSURLSessionDownloadTask *)downloadFileWithUrl:(NSString *)url
                                          dirPath:(NSString *)dirPath
                                         filename:(NSString *)filename
                                       onComplete:(onDownloadRespBlock)onComplete
                                       onProgress:(onProgressBlock)onProgress;

@end

@interface ZBResponseModel : NSObject

@property (nonatomic, copy) NSHTTPURLResponse *response;
@property (nonatomic, copy) NSDictionary *httpHeaders;
@property (nonatomic, copy) NSData *responseData;
@property (nonatomic, copy) NSDictionary *responseJson;

@end

@interface ZBDownLoadRespModel : NSObject

@property (nonatomic, strong) NSURLResponse *response;
@property (nonatomic, strong) NSURL *filePath;
@property (nonatomic, strong) NSError *error;

@end
